﻿/************************************************************************

   Extended Silverlight Toolkit

   Copyright (C) 2010-2012 Xceed Software Inc.

   This program is provided to you under the terms of the Microsoft Public
   License (Ms-PL) as published at http://extendedsilverlight.codeplex.com/license

   Please purchase a commercial version of this toolkit if you are using
   it in a commercial product. The commercial versions support the project,
   and also include more features for each control, priority support,
   source code, updates, removed watermark, and a proprietary license.

   Visit http://xceed.com and follow @datagrid on Twitter.

  **********************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using Xceed.Silverlight.Data;
using Xceed.Silverlight.Data.Stats;

namespace Xceed.Silverlight.DataGrid
{
  public partial class DataGridControl
  {
    private class GroupConfigurationSelectorAdapter : IGroupHeadersFootersSelector, IGroupStatFunctionsSelector
    {
      #region Constructor

      internal GroupConfigurationSelectorAdapter( DataGridControl dataGridControl )
      {
        if( dataGridControl == null )
          throw new ArgumentNullException( "dataGridControl" );

        m_dataGridControl = dataGridControl;
      }

      #endregion

      #region IGroupHeadersFootersConfigurationProvider Members

      public bool HasHeaders( DataPath dataPath )
      {
        return this.GetHeaders(dataPath).Any();
      }

      public bool HasFooters( DataPath dataPath )
      {
        return this.GetFooters(dataPath).Any();
      }

      public IEnumerable<object> GetHeaders( DataPath dataPath )
      {

        return Enumerable.Empty<object>();
      }

      public IEnumerable<object> GetFooters( DataPath dataPath )
      {

        return Enumerable.Empty<object>();
      }

      public IEnumerable<DataPath> GetExceptionHeaders()
      {
        return Enumerable.Empty<DataPath>();
      }

      public IEnumerable<DataPath> GetExceptionFooters()
      {
        return Enumerable.Empty<DataPath>();
      }

      #endregion

      #region IGroupStatFunctionsSelector Members

      public IEnumerable<StatFunction> GetStatFunctions( DataPath groupPath )
      {
        List<DataGridGroupConfiguration> configList = m_dataGridControl.GetGroupConfigurationForPath( groupPath );
        DataGridGroupConfiguration config = configList.First();

        return ( config != null )
          ? config.StatFunctions
          : Enumerable.Empty<StatFunction>();
      }

      #endregion

      #region Private Fields

      private readonly DataGridControl m_dataGridControl;

      #endregion
    }
  }
}
